// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Nodes.Json;

public sealed partial class NodeStatsMetricConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric>
{
	private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("_all");
	private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("_none");
	private static readonly System.Text.Json.JsonEncodedText MemberAdaptiveSelection = System.Text.Json.JsonEncodedText.Encode("adaptive_selection");
	private static readonly System.Text.Json.JsonEncodedText MemberAllocations = System.Text.Json.JsonEncodedText.Encode("allocations");
	private static readonly System.Text.Json.JsonEncodedText MemberBreaker = System.Text.Json.JsonEncodedText.Encode("breaker");
	private static readonly System.Text.Json.JsonEncodedText MemberDiscovery = System.Text.Json.JsonEncodedText.Encode("discovery");
	private static readonly System.Text.Json.JsonEncodedText MemberFs = System.Text.Json.JsonEncodedText.Encode("fs");
	private static readonly System.Text.Json.JsonEncodedText MemberHttp = System.Text.Json.JsonEncodedText.Encode("http");
	private static readonly System.Text.Json.JsonEncodedText MemberIndexingPressure = System.Text.Json.JsonEncodedText.Encode("indexing_pressure");
	private static readonly System.Text.Json.JsonEncodedText MemberIndices = System.Text.Json.JsonEncodedText.Encode("indices");
	private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest");
	private static readonly System.Text.Json.JsonEncodedText MemberJvm = System.Text.Json.JsonEncodedText.Encode("jvm");
	private static readonly System.Text.Json.JsonEncodedText MemberOs = System.Text.Json.JsonEncodedText.Encode("os");
	private static readonly System.Text.Json.JsonEncodedText MemberProcess = System.Text.Json.JsonEncodedText.Encode("process");
	private static readonly System.Text.Json.JsonEncodedText MemberRepositories = System.Text.Json.JsonEncodedText.Encode("repositories");
	private static readonly System.Text.Json.JsonEncodedText MemberScript = System.Text.Json.JsonEncodedText.Encode("script");
	private static readonly System.Text.Json.JsonEncodedText MemberScriptCache = System.Text.Json.JsonEncodedText.Encode("script_cache");
	private static readonly System.Text.Json.JsonEncodedText MemberThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool");
	private static readonly System.Text.Json.JsonEncodedText MemberTransport = System.Text.Json.JsonEncodedText.Encode("transport");

	public override Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		if (reader.ValueTextEquals(MemberAll))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.All;
		}

		if (reader.ValueTextEquals(MemberNone))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.None;
		}

		if (reader.ValueTextEquals(MemberAdaptiveSelection))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.AdaptiveSelection;
		}

		if (reader.ValueTextEquals(MemberAllocations))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Allocations;
		}

		if (reader.ValueTextEquals(MemberBreaker))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Breaker;
		}

		if (reader.ValueTextEquals(MemberDiscovery))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Discovery;
		}

		if (reader.ValueTextEquals(MemberFs))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Fs;
		}

		if (reader.ValueTextEquals(MemberHttp))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Http;
		}

		if (reader.ValueTextEquals(MemberIndexingPressure))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.IndexingPressure;
		}

		if (reader.ValueTextEquals(MemberIndices))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Indices;
		}

		if (reader.ValueTextEquals(MemberIngest))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Ingest;
		}

		if (reader.ValueTextEquals(MemberJvm))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Jvm;
		}

		if (reader.ValueTextEquals(MemberOs))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Os;
		}

		if (reader.ValueTextEquals(MemberProcess))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Process;
		}

		if (reader.ValueTextEquals(MemberRepositories))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Repositories;
		}

		if (reader.ValueTextEquals(MemberScript))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Script;
		}

		if (reader.ValueTextEquals(MemberScriptCache))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ScriptCache;
		}

		if (reader.ValueTextEquals(MemberThreadPool))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ThreadPool;
		}

		if (reader.ValueTextEquals(MemberTransport))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Transport;
		}

		var value = reader.GetString()!;
		if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.All;
		}

		if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.None;
		}

		if (string.Equals(value, MemberAdaptiveSelection.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.AdaptiveSelection;
		}

		if (string.Equals(value, MemberAllocations.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Allocations;
		}

		if (string.Equals(value, MemberBreaker.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Breaker;
		}

		if (string.Equals(value, MemberDiscovery.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Discovery;
		}

		if (string.Equals(value, MemberFs.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Fs;
		}

		if (string.Equals(value, MemberHttp.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Http;
		}

		if (string.Equals(value, MemberIndexingPressure.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.IndexingPressure;
		}

		if (string.Equals(value, MemberIndices.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Indices;
		}

		if (string.Equals(value, MemberIngest.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Ingest;
		}

		if (string.Equals(value, MemberJvm.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Jvm;
		}

		if (string.Equals(value, MemberOs.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Os;
		}

		if (string.Equals(value, MemberProcess.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Process;
		}

		if (string.Equals(value, MemberRepositories.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Repositories;
		}

		if (string.Equals(value, MemberScript.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Script;
		}

		if (string.Equals(value, MemberScriptCache.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ScriptCache;
		}

		if (string.Equals(value, MemberThreadPool.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ThreadPool;
		}

		if (string.Equals(value, MemberTransport.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Transport;
		}

		throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric)}'.");
	}

	public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric value, System.Text.Json.JsonSerializerOptions options)
	{
		switch (value)
		{
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.All:
				writer.WriteStringValue(MemberAll);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.None:
				writer.WriteStringValue(MemberNone);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.AdaptiveSelection:
				writer.WriteStringValue(MemberAdaptiveSelection);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Allocations:
				writer.WriteStringValue(MemberAllocations);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Breaker:
				writer.WriteStringValue(MemberBreaker);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Discovery:
				writer.WriteStringValue(MemberDiscovery);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Fs:
				writer.WriteStringValue(MemberFs);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Http:
				writer.WriteStringValue(MemberHttp);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.IndexingPressure:
				writer.WriteStringValue(MemberIndexingPressure);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Indices:
				writer.WriteStringValue(MemberIndices);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Ingest:
				writer.WriteStringValue(MemberIngest);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Jvm:
				writer.WriteStringValue(MemberJvm);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Os:
				writer.WriteStringValue(MemberOs);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Process:
				writer.WriteStringValue(MemberProcess);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Repositories:
				writer.WriteStringValue(MemberRepositories);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Script:
				writer.WriteStringValue(MemberScript);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ScriptCache:
				writer.WriteStringValue(MemberScriptCache);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.ThreadPool:
				writer.WriteStringValue(MemberThreadPool);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric.Transport:
				writer.WriteStringValue(MemberTransport);
				break;
			default:
				throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric)}'.");
		}
	}

	public override Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		return Read(ref reader, typeToConvert, options);
	}

	public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Nodes.NodeStatsMetric value, System.Text.Json.JsonSerializerOptions options)
	{
		Write(writer, value, options);
	}
}